package com.niiwoo.civet.trade.dao.mapper;

import com.niiwoo.civet.trade.dao.entity.ProjectPackage;
import com.niiwoo.civet.trade.dto.request.intelligenceInvest.IntelligenceInvestPageRequestDTO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;

@Component
public interface ProjectPackageMapperExt extends ProjectPackageMapper {

    ProjectPackage selectByPrimaryKeyForUpdate(@Param("packageId")Long packageId);

    List<ProjectPackage> queryProjectPackageListByServiceConfigIdAndPackagePublishChannelCodeAndStatus(@Param("serviceConfigId") Long serviceConfigId,
                                                                                                       @Param("packagePublishChannelCode") String packagePublishChannelCode, @Param("status") Byte status);

    List<ProjectPackage> queryWaitingPublish();

    List<ProjectPackage> queryProjectPackageListByParam(@Param("channelCode") String channelCode,
                                                        @Param("deadlineUnit") Byte deadlineUnit,
                                                        @Param("deadline") Integer deadline,
                                                        @Param("borrowRate") BigDecimal borrowRate,
                                                        @Param("repaymentType") Byte repaymentType,
                                                        @Param("packagePublishChannelCode") String packagePublishChannelCode,
                                                        @Param("status")Byte status);

    List<ProjectPackage> getIntelligenceInvestList(@Param("params") IntelligenceInvestPageRequestDTO requestDTO);

    List<Integer> getIntelligenceInvestCount(@Param("params") IntelligenceInvestPageRequestDTO requestDTO);

    ProjectPackage selectByDeadlineAndStatus(@Param("deadUnit")Byte deadUnit,
                                             @Param("deadLine")Integer deadLine,
                                             @Param("status") Byte status,
                                             @Param("sortOrder") Byte sortOrder,
                                             @Param("repaymentType") Byte repaymentType,
                                             @Param("packageType") Byte packageType);
    /**
     * 查询当前已经到截至期的智能投包
     * 条件默认 截至时间+10分钟（为了异步的投资都能触发）
     * 状态 投资中
     * @return
     */
	List<ProjectPackage> selectEndTimeProjectPackage();

    List<ProjectPackage> getIntelligenceUnInvestList(@Param("params") IntelligenceInvestPageRequestDTO requestDTO);

    List<Integer> getIntelligenceUnInvestCount(@Param("params") IntelligenceInvestPageRequestDTO requestDTO);


    HashMap<String,BigDecimal> selectPackageListByRate(@Param("params") IntelligenceInvestPageRequestDTO requestDTO);

    List<HashMap<String,Object>> selectProjectInvestingListByDeadLine(@Param("params") IntelligenceInvestPageRequestDTO requestDTO);

    HashMap<String,BigDecimal> selectPackageByStartInvestAmount(@Param("params") IntelligenceInvestPageRequestDTO requestDTO);

    Integer queryIntelligenceInvestCount(@Param("userIdentity") Byte userIdentity,@Param("code") Byte code);
}